import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Test1{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 0;
        n = sc.nextInt();
        int[][] num = new int[n][];
        // 获取数据
        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();
            num[i] = new int[count];
            for (int j = 0; j < count; j++) {
                num[i][j] = sc.nextInt();
            }
            Arrays.sort(num[i]);
        }
        Arrays.sort(num);
        System.out.println(num);
    }
}
